package com.app.base.service.core.recruit.controller;


import com.app.base.model.vo.RecruitSearchVo;
import com.app.base.service.core.recruit.entity.RecruitDetail;
import com.app.base.service.core.recruit.service.RecruitDetailService;
import com.app.base.utlis.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 招聘信息发布表 前端控制器
 * @author yuhag
 * @since 2022-05-16
 */
@RestController
@RequestMapping("/recruitDetailController")
@Api(tags = "招聘模块")
public class RecruitDetailController {

    @Resource
    private RecruitDetailService recruitDetailService;

    @GetMapping("pageRecruit")
    @ApiOperation("招聘简章分页")
    public Result pageRecruit(@RequestParam(value = "current",defaultValue = "1") Long current,
                              @RequestParam(value = "pageSize",defaultValue = "5") Long pageSize,
                              RecruitSearchVo recruitSearchVo){
        return recruitDetailService.pageRecruit(current,pageSize,recruitSearchVo);
    }


    @PostMapping("saveOrUpdateRecruit")
    @ApiOperation("更新或者添加招聘信息")
    public Result saveOrUpdateRecruit(@RequestBody RecruitDetail recruit, HttpServletRequest request){
        return recruitDetailService.saveOrUpdateRecruit(recruit,request);
    }

    @GetMapping("getByIdRecruit/{id}")
    @ApiOperation("根据id回显招聘信息")
    public Result getByIdRecruit(@PathVariable(value = "id") String id){
        return recruitDetailService.getByIdRecruit(id);
    }


    @PostMapping("file/{id}")
    @ApiOperation("归档招聘简章")
    public Result file(@PathVariable("id")String id){
        return recruitDetailService.file(id);
    }

    @DeleteMapping("del/{id}")
    @ApiOperation("删除招聘简章")
    public Result del(@PathVariable("id")String id){
        return recruitDetailService.del(id);
    }


}

